package com.comleader.operator.common.page;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.mybatisflex.core.paginate.Page;

import lombok.Data;

@Data
public class PageQuery {

    /**
     * 当前页码，从1开始
     */
    @Min(value = 1, message = "当前页码最小为1")
    @NotNull(message = "当前页码不能为空")
    private Integer pageNum;

    /**
     * 每页数量
     */
    @NotNull(message = "每页数量不能为空")
    private Integer pageSize;

    public static Page build(PageQuery pageQuery) {
        return Page.of(pageQuery.getPageNum(), pageQuery.getPageSize());
    }
}